package org.szpshang.system.role.service.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.szpshang.bean.JsonDataBean;
import org.szpshang.framework.support.dao.hibernate.impl.BaseDao;
import org.szpshang.system.role.entity.SysRole;
import org.szpshang.system.role.service.RoleService;

@Service("roleService")
public class RoleServiceImpl implements RoleService {

	protected Log logger = LogFactory.getLog(this.getClass());

	@Autowired
	protected BaseDao baseDao;
	
	@Override
	public JsonDataBean getRole(int start,int limit) {
		return baseDao.findPageByHql(start, limit, " from SysRole t where 1=1");
	}
	
	@Override
	public SysRole getRole(Integer id) {
		return baseDao.get(SysRole.class,id);
	}

	@Override
	public void addRole(SysRole sysRole) {
		baseDao.save(sysRole);
	}

	@Override
	public void editRole(SysRole sysRole) {
		baseDao.update(sysRole);
		
	}

	@Override
	public void deleteRole(String[] ids) {
		Integer[] i = new Integer[ids.length];
		for(int index=0;index<ids.length;index++){
			i[index]=Integer.parseInt(ids[index]);
		}
		baseDao.delete(SysRole.class,i);
	}
	
}
